{include file="public/layout" /}

<body style="background-color: rgb(255, 255, 255); overflow: auto; cursor: default; -moz-user-select: inherit;">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page">
    {include file="guestbook/bar" /}
    <div class="flexigrid">
        <div class="mDiv">
            <div class="ftitle">
                <h3>{$arctype_info.typename|default=''}</h3>
                <h5>(共{$pager->totalRows}条记录)</h5>
            </div>
            <div title="刷新数据" class="pReload"><i class="fa fa-refresh"></i></div>
            <form class="navbar-form form-inline" action="{:U('Guestbook/attribute_index')}" method="get" onsubmit="layer_loading('正在处理');">
                <div class="sDiv">
                    <div class="sDiv2">
                        <input type="hidden" name="typeid" id="typeid" value="{$Request.param.typeid|default=''}">
                        <input type="text" size="30" name="keywords" value="{$Request.param.keywords}" class="qsbox" placeholder="名称搜索...">
                        <input type="submit" class="btn" value="搜索">
                    </div>
                    <div class="sDiv2">
                        <input type="button" class="btn" value="重置" onClick="window.location.href='{:U('Guestbook/attribute_index', array("typeid"=>$Request.param.typeid))}';">
                    </div>
                </div>
            </form>
        </div>
        <div class="hDiv">
            <div class="hDivBox">
                <table cellspacing="0" cellpadding="0" style="width: 100%">
                    <thead>
                    <tr>
                        <th class="sign w40" axis="col0">
                            <div class="tc">选择</div>
                        </th>
                        <th abbr="article_title" axis="col3" class="w40">
                            <div class="tc">ID</div>
                        </th>
                        <th abbr="article_title" axis="col3" class="">
                            <div style="text-align: left; padding-left: 10px;" class="">表单提示文字</div>
                        </th>
                        <th abbr="article_title" axis="col3"  class="w100">
                            <div class="tc">字段名称</div>
                        </th>
                        <th abbr="article_time" axis="col6" class="w100">
                            <div class="tc">表单类型</div>
                        </th>
                        <th abbr="article_time" axis="col6" class="w100">
                            <div class="tc">所属栏目</div>
                        </th>
                        <th abbr="article_time" axis="col6" class="w160">
                            <div class="tc">更新时间</div>
                        </th>
                        <th axis="col1" class="w180">
                            <div class="tc">操作</div>
                        </th>
                        
                    </tr>
                    </thead>
                </table>
            </div>
        </div>
        <div class="bDiv" style="height: auto;">
            <div id="flexigrid" cellpadding="0" cellspacing="0" border="0">
                <table>
                    <tbody>
                    {empty name="list"}
                        <tr>
                            <td class="no-data" align="center" axis="col0" colspan="50">
                                <i class="fa fa-exclamation-circle"></i>没有符合条件的记录
                            </td>
                        </tr>
                    {else/}
                        {volist name="list" id="vo" key="k"}
                        <tr>
                            <td class="sign">
                                <div class="tc w40"><input type="checkbox" name="ids[]" value="{$vo.attr_id}"></div>
                            </td>
                            <td class="sort">
                                <div class="tc w40">
                                    {$vo.attr_id}
                                </div>
                            </td>
                            <td style="width: 100%">
                                <div style="text-align: left; padding-left: 10px;">
                                    {eq name="'Guestbook@attribute_edit'|is_check_access" value="1"}
                                    <a href="{:U('Guestbook/attribute_edit',array('id'=>$vo['attr_id']))}">{$vo.attr_name}</a>
                                    {else /}
                                    {$vo.attr_name}
                                    {/eq}
                                </div>
                            </td>
                            <td class="">
                                <div class="w100 tc">
                                    {$vo.fieldname|default=''}
                                </div>
                            </td>
                            <td align="center" class="">
                                <div class="w100 tc">
                                    {$attrInputTypeArr[$vo['attr_input_type']]|default=''}
                                </div>
                            </td>
                            <td class="">
                                <div class="w100 tc">{$vo.typename|default='<i class="red">数据出错！</i>'}</div>
                            </td>
                            <td>
                                <div class="w160 tc">
                                    {$vo.update_time|date='Y-m-d H:i:s',###}
                                </div>
                            </td>
                            <td>
                                <div class="w180 tc">
                                    {eq name="'Guestbook@attribute_edit'|is_check_access" value="1"}
                                    <a href="{:U('Guestbook/attribute_edit',array('id'=>$vo['attr_id']))}" class="btn blue"><i class="fa fa-pencil-square-o"></i>编辑</a>
                                    {/eq}
                                    {eq name="'Guestbook@attribute_del'|is_check_access" value="1"}
                                    <a class="btn red"  href="javascript:void(0);" data-url="{:U('Guestbook/attribute_del')}" data-id="{$vo.attr_id}" onClick="delfun(this);"><i class="fa fa-trash-o"></i>删除</a>
                                    {/eq}
                                    <a class="btn blue" href="javascript:void(0);" onclick="copyToClipBoard('{$vo.fieldname}', 'itemname_{$vo.attr_id}', {$vo.attr_input_type|default='0'})">标签调用</a>
                                </div>
                            </td>
                           
                        </tr>
                        {/volist}
                    {/empty}
                    </tbody>
                </table>
            </div>
            <div class="iDiv" style="display: none;"></div>
        </div>
        <div class="tDiv">
            <div class="tDiv2">
                <div class="fbutton checkboxall">
                    <input type="checkbox" onclick="javascript:$('input[name*=ids]').prop('checked',this.checked);">
                </div>
                {eq name="'Guestbook@attribute_del'|is_check_access" value="1"}
                <div class="fbutton">
                    <a onclick="batch_del(this, 'ids');" data-url="{:U('Guestbook/attribute_del')}">
                        <div class="add" title="批量删除">
                            <span><i class="fa fa-close"></i>批量删除</span>
                        </div>
                    </a>
                </div>
                {/eq}
                {eq name="'Guestbook@attribute_add'|is_check_access" value="1"}
                <div class="fbutton">
                    <a href="{:U('Guestbook/attribute_add', array('typeid'=>$Request.param.typeid))}">
                        <div class="add" title="新增表单">
                            <span class="red"><i class="fa fa-plus"></i>新增表单</span>
                        </div>
                    </a>
                </div>
                {/eq}
            </div>
            <div style="clear:both"></div>
        </div>
        <!--分页位置-->
        {$page}
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function(){

        // 表格行点击选中切换
        $('#flexigrid > table>tbody >tr').click(function(){
            $(this).toggleClass('trSelected');
        });

        // 点击刷新数据
        $('.fa-refresh').click(function(){
            location.href = location.href;
        });
    });

    /**
     * 代码调用js
     * @param id  id
     * @param limit 条数
     */
    function copyToClipBoard(fieldname, attr_name, attr_input_type) {
        if (1 == attr_input_type) {
            var liststr = "<select name='{$"+"field."+fieldname+"}' id='"+fieldname+"'>\r\n    <option value='无'>无</option>\r\n    {eyou:volist name='$"+"field.options' id='vo'}\r\n        <option value='{$"+"vo.value}'>{$"+"vo.value}</option>\r\n    {/eyou:volist"+"}\r\n</select>";
            var contentdiv = '<div class="dialog_content" style="margin: 0px; padding: 0px;"><dl style="padding:10px 30px;line-height:30px;"><dd>表单提示文字：</dd>'
            contentdiv += '<dd><input type="text" style=" width:400px;margin-bottom:10px;" value="{$'+'field.'+attr_name+'}"></dd>'
            contentdiv += '<dd>下列框列表：</dd>'
            contentdiv += '<dd><textarea rows="4" cols="60" style="width:400px;height:110px;">' + liststr + '</textarea></dd>'
            height = '230px';

        } else {
            var contentdiv = '<div class="dialog_content" style="margin: 0px; padding: 0px;"><dl style="padding:10px 30px;line-height:30px;"><dd>表单提示文字：</dd>'
            contentdiv += '<dd><input type="text" style=" width:400px;margin-bottom:10px;" value="{$'+'field.'+attr_name+'}"></dd>'
            contentdiv += '<dd>字段名称：</dd>'
            contentdiv += '<dd><input type="text" style=" width:400px;margin-bottom:10px;" value="{$'+'field.'+fieldname+'}"></dd>'
            height = '230px';
        }
        contentdiv += '<dd style="border-top: dotted 1px #E7E7E7; color: #F60;">请将相应标签复制并粘贴到对应模板文件中！</dd></dl></div>'
        layer.open({
            title: '标签调用',
            type: 1,
            skin: 'layui-layer-demo',
            area: ['480px', '330px'], //宽高
            content: contentdiv
        });
    }
</script>

{include file="public/footer" /}